// pages/index/orderNum/selectTime/selectTime.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    acticeFlag: 0,
    scheduleData: [{
      dayName: '显示明天排班',
      dayData: '2020/8/21',
      timeData: [{
        id: 0,
        time: '9: 00',
        state: 0,   //0：default    1：none
      }, {
        id: 1,
        time: '9: 00',
        state: 1,
      }, {
        id: 2,
        time: '9: 00',
        state: 0,
      }, {
        id: 3,
        time: '9: 00',
        state: 0,
      }, {
        id: 4,
        time: '9: 00',
        state: 0,
      }, {
        id: 5,
        time: '9: 00',
        state: 0,
      }],
    },{
      dayName: '显示明天排班',
      dayData: '2020/8/21',
      timeData: [{
        id: 6,
        time: '9: 00',
        state: 0,   //0：default    1：none
      }, {
        id: 7,
        time: '9: 00',
        state: 1,
      }, {
        id: 8,
        time: '9: 00',
        state: 0,
      }, {
        id: 9,
        time: '9: 00',
        state: 0,
      }, {
        id: 10,
        time: '9: 00',
        state: 0,
      }, {
        id: 11,
        time: '9: 00',
        state: 0,
      }],
    },{
      dayName: '显示明天排班',
      dayData: '2020/8/21',
      timeData: [{
        id: 12,
        time: '9: 00',
        state: 0,   //0：default    1：none
      }, {
        id: 13,
        time: '9: 00',
        state: 1,
      }, {
        id: 14,
        time: '9: 00',
        state: 0,
      }, {
        id: 15,
        time: '9: 00',
        state: 0,
      }, {
        id: 16,
        time: '9: 00',
        state: 0,
      }, {
        id: 17,
        time: '9: 00',
        state: 0,
      }],
    }, ],
    
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    const eventChannel = this.getOpenerEventChannel()
    // 监听hospitalsDate事件，获取上一页面通过eventChannel传送到当前页面的数据
    eventChannel.on('doctorsData', function (data) {
      console.log('来自doctorsData的数据:', data)
    })
  },

  clickTime(e) {
    let cilckId = this.data.scheduleData[e.target.dataset.index].timeData[e.target.dataset.indexchilren].id
    this.setData({
      acticeFlag: cilckId,
    })
  },

  goPatientInof() {
    wx.navigateTo({
      url: '../patientInfo/patientInfo',
      events: {
        selectTimeData(data) {console.log(data)}
      },
      success: (res) => {
        // 通过eventChannel向被打开页面传送数据
        res.eventChannel.emit('selectData', { data: this.data.acticeFlag })
      },
      fail: (err) => {console.log('err', err)},
      complete: () => {}
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})